package com.bum.api.processor.keeng.html;

import org.apache.commons.lang.StringUtils;

import com.bum.api.core.exp.om.Metas;
import com.bum.api.core.exp.om.Params;
import com.bum.api.core.service.process.ApiProcess;
import com.bum.api.processor.keeng.html.bo.KeengHtmlViewBO;

public class KeengHtmlProcess extends ApiProcess {
	KeengHtmlViewBO	keengHtmlViewBO;

	enum Func {
		home,
		song,
		albums,
		album,
		top
	}

	@Override
	public String process(String path, Params params, Metas metas) {
		String[] parts = StringUtils.split(path, "/", 3);

		Func func = null;
		if (parts.length < 2) {
			func = Func.home;
		} else {
			func = Func.valueOf(parts[1]);
		}

		switch (func) {
			case home:
				return keengHtmlViewBO.home(null, params, metas);

			case albums:
				return keengHtmlViewBO.albums(parts.length == 3 ? parts[2] : null, params, metas);

			case album:
				return keengHtmlViewBO.album(parts[2], params, metas);

			default:
				break;
		}

		return keengHtmlViewBO.home(path, params, metas);
	}

	public void setKeengHtmlViewBO(KeengHtmlViewBO keengHtmlViewBO) {
		this.keengHtmlViewBO = keengHtmlViewBO;
	}

}
